import { _decorator, Component, Node, Slider } from 'cc';
import { SaveMgr } from '../mgr/SaveMgr';
import { AudioMgr } from '../mgr/AudioMgr';
const { ccclass, property } = _decorator;

@ccclass('SetPanel')
export class SetPanel extends Component {

    @property(Slider) musicS:Slider;
    @property(Slider) effectS;
    start() {

        //AudioMgr.Inst.playMusic("bg1");

        this.musicS.progress=SaveMgr.Inst.Data.musicVal;
        this.effectS.progress=SaveMgr.Inst.Data.effectVal;

        this.musicS.node.on('slide',(s)=>{
            SaveMgr.Inst.Data.musicVal=s.progress;
            AudioMgr.Inst.setMusicVolume(SaveMgr.Inst.Data.musicVal);
        },this);

        this.effectS.node.on('slide',(s)=>{
            SaveMgr.Inst.Data.effectVal=s.progress;
            AudioMgr.Inst.setEffectVolume(SaveMgr.Inst.Data.effectVal);
        },this);
    }

    protected onDisable(): void {
       
    }

    closePanel(){
        this.node.active=false;
       AudioMgr.Inst.playEffect("bel");
        SaveMgr.Inst.saveData();
    }

}


